package greatwall.myreader;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainInterface extends Activity{
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_interface);
        BindControls();
        BindListener();
    }
	private Button BtnSearch;		//搜索按钮
	private EditText ETSearch;		//搜索内容
	private Button BtnHot;			//每周热榜
	private Button BtnCategory;		//图书分类
	
	private void BindControls()
	{
		ETSearch = (EditText)findViewById(R.id.search_edit);		//搜索内容
		BtnHot = (Button)findViewById(R.id.latest_book);			//每周热榜
		BtnSearch = (Button)findViewById(R.id.search);
		BtnCategory = (Button)findViewById(R.id.book_sort);
		
	}
	
	private OnClickListener searchListner = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			String search = ETSearch.getText().toString();
			if(search == null && search.equals("") == true)
			{
				Toast.makeText(getApplicationContext(), "请输入搜索内容", Toast.LENGTH_LONG);
				return;
			}
			Bundle b = new Bundle();
			b.putString("searchcontent", search);
			Intent in = new Intent();
			in.putExtras(b);			
			in.setClass(MainInterface.this, ShowSearchBookList.class);
			startActivity(in);
		}
	};
	
	private OnClickListener changeListener = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			Intent in = new Intent();
			if(v == BtnHot)
			{				
//				in.setClass(MainInterface.class, cls)
//				startActivity(in)
			}
			else
			{
				in.setClass(MainInterface.this, ShowCategoryNameList.class);
				startActivity(in);
			}
		}
	};
	
	private void BindListener()
	{
		BtnSearch.setOnClickListener(searchListner);
		BtnHot.setOnClickListener(changeListener);
		BtnCategory.setOnClickListener(changeListener);
	}
	
	
}
